package casia.isiteam.springbootshiro.model.po.common;

import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.Date;
import java.util.List;

/**
 * Author wzy
 * Date 2018/1/15 14:48
 */
public interface UserInfoRepository extends JpaRepository<UserInfo,Integer> {
    /**
     * 通过用户名查找
     * @param username
     * @return
     */
    UserInfo findByUsername(String username);

    /**
     * 通过部门与角色查找
     * @param depId
     * @param role
     * @return
     */
    List<UserInfo> findAllByDepIdAndRoleAndInstIdNot(int depId, int role ,int Inst_id,Pageable pageable);
    /**
     * 查询无效用户
     * @return
     */
    @Query("select u from UserInfo u where u.deadline< ?1 and u.status = ?2")
    List<UserInfo> queryAllInvalidUsers(Date nowDate, int status);
}
